﻿Public Class frm_login
    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

    End Sub

    Private Sub Label2_Click(sender As Object, e As EventArgs) Handles lbl_name.Click

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btn_clear.Click
        txt_name.Text = ""
        txt_pwd.Text = ""

    End Sub

    Private Sub btn_confirm_Click(sender As Object, e As EventArgs) Handles btn_confirm.Click
        If txt_name.Text = "" Or txt_pwd.Text = "" Then
            MessageBox.Show("用户名和密码不能为空", "请注意")
            Return
        End If
        ' MessageBox.Show("name:" & txt_name.Text & "pwd:" & txt_pwd.Text)
        Dim isValidUser As Boolean = LoginService.isValidUser(txt_name.Text, txt_pwd.Text, 1)

        If isValidUser = True Then
            ExamGlobal.LOGIN_NAME = txt_name.Text
            'ExamMgm.Show()
            MainForm.Show()
            Me.Hide()
            'MessageBox.Show("登录成功 ！name:" & txt_name.Text & "pwd:" & txt_pwd.Text)
        Else
            MessageBox.Show("登录失败。。用户名密码不正确！name:" & txt_name.Text & "pwd:" & txt_pwd.Text)
        End If
    End Sub

    Private Sub frm_login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Top = (My.Computer.Screen.Bounds.Height - Me.Height) / 2
        Me.Left = (My.Computer.Screen.Bounds.Width - Me.Width) / 2
    End Sub

    Private Sub txt_pwd_TextChanged(sender As Object, e As EventArgs) Handles txt_pwd.TextChanged

    End Sub

    Private Sub txt_pwd_KeyDown(sender As Object, e As KeyEventArgs) Handles txt_pwd.KeyDown
        If e.KeyCode = 13 Then
            btn_confirm_Click(sender, e)
        End If
    End Sub

    Private Sub frm_login_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        End
    End Sub
End Class